布置环境
# 在家目录创建环境/home/myz/clash
$ mkdir clash
$ cd clash
# 下载clash包
先在windows中进入网址下载https://down.clash.la/Clash/Core/Releases/clash-linux-amd64-v1.18.0.gz ,然后传入linux中(因为linux好像连不上该网址)
$ gzip -d clash-linux-amd64-v1.18.0.gz
$ mv clash-linux-amd64-v1.18.0 clash
# 这里clash为二进制可以运行文件了
$ chmod 755 clash
传入配置
# 生成默认配置
$ ./clash -d . # 默认配置
输入该命令后会出现几行东西,然后就卡住了,这时候我认为其实是clash处于开启状态了,可以新开一个终端查看是否有如下文件:
有的话表示默认配置已经创建完成了。
# 拉取机场配置,注意: 名称为:config.yaml
我用的是nanoport,我直接在windows端的clash-profile中打开配置,上传到Linux上,要注意把名称改为config.yaml,然后覆盖掉默认配置中的config.yaml
$ wget xxxx # 要么拉下来 要么自己拷贝上来
$ ./clash -d . # 就开始加载你的配置了,同样会卡住,应该就是指正在运行了,ctrl+c退出
日常使用
ctrl+c退出后应该就取消代理了,下面我们直接添加到环境变量中:
vim ~/..bashrc开始准备命令并把下面的写进入
alias clash_start="screen -S clash /home/myz/clash/clash -d /home/myz/clash/"
alias clash_stop="pkill clash"
alias proxy_on="export https_proxy=127.0.0.1:7890 && export http_proxy=127.0.0.1:7890"
alias proxy_off="unset http_proxy https_proxy"
source ~/.bashrc 重新载入
clash_start会进入screen 按 ctrl + a + d退出后台
proxy_on开启代理
curl https://www.youtube.com/会发现马上返回结果
Github加速
先用git config –list查看自己的git是否已有配置,如果有了可以先删掉:
$ git config --global --unset user.name
$ git config --global --edit #打开编辑器删除
然后输入下面两条配置成功
$ git config --global http.proxy 'http://127.0.0.1:7890'
$ git config --global https.proxy 'https://127.0.0.1:7890'